﻿ using Coldairarrow.Business.PB;
using Coldairarrow.Entity;
using Coldairarrow.Entity.DTO;
using Coldairarrow.Entity.PB;
using Coldairarrow.Entity.Print;
using Coldairarrow.Util;
using Coldairarrow.Util.ClassLibrary;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Options;
using NPOI.HSSF.UserModel;
using NPOI.SS.UserModel;
using NPOI.XSSF.UserModel;
using System;
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;

namespace Coldairarrow.Api.Controllers.PB
{
    [Route("/PB/[controller]/[action]")]
    public class PB_JobBookingController : BaseApiController
    {
        #region DI
        private readonly RedisOptions _redisOptions; //1.声明实体
        private readonly MongoDBOptions _mongodbOptions;
        public PB_JobBookingController(IPB_JobBookingBusiness pB_JobBookingBus, IOptions<MongoDBOptions> mongodbOptions, IOptions<RedisOptions> redisOptions)
        {
            _pB_JobBookingBus = pB_JobBookingBus;
            _mongodbOptions = mongodbOptions.Value;
            _redisOptions = redisOptions.Value;//3.赋值
        }

        IPB_JobBookingBusiness _pB_JobBookingBus { get; }

        #endregion

        #region 获取

        [HttpPost]
        public async Task<PageResult<PB_JobBooking>> GetDataList(PageInput<ConditionDTO> input)
        {
            return await _pB_JobBookingBus.GetDataListAsync(input);
        }

        /// <summary>
        /// 获取报工list
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<PageResult<PB_JobBookingDTO>> GetWorkReportDataListAsync(PageInput<ConditionDTO> input)
        {
            return await _pB_JobBookingBus.GetWorkReportDataListAsync(input);
        }

        /// <summary>
        /// 获取质检List
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<PageResult<PB_JobBookingDTO>> GetQualityDataListAsync(PageInput<ConditionDTO> input)
        {
            return await _pB_JobBookingBus.GetQualityDataListAsync(input);
        }

        [HttpPost]
        public async Task<PB_JobBooking> GetTheData(IdInputDTO input)
        {
            return await _pB_JobBookingBus.GetTheDataAsync(input.id);
        }
        [HttpPost]
        public async Task<MonthSummary> GetMonthSummary(string month) {
            return await _pB_JobBookingBus.GetMonthSummary(month);
        }

        /// <summary>
        /// PDA报工完获取当前报工信息
        /// </summary>
        /// <param name="OrderDetailQrCode">任务单明细二维码</param>
        /// <returns></returns>
        [HttpPost]
        public async Task<List<PB_JobBookingDTO>> GetTheDataDeatil(string OrderDetailQrCode)
        {
            return await _pB_JobBookingBus.GetTheDataDeatil(OrderDetailQrCode);
        }

        /// <summary>
        /// PDA报工完获取当前报工信息（输入）
        /// </summary>
        /// <param name="OrderDetailQrCode">任务单明细二维码</param>
        /// <returns></returns>
        [HttpPost]
        public async Task<List<PB_JobBookingDTO>> GetTheDataDeatilInput(string OrderDetailQrCode)
        {
            return await _pB_JobBookingBus.GetTheDataDeatilInput(OrderDetailQrCode);
        }

        /// <summary>
        /// 解析二维码通用接口
        /// </summary>
        /// <param name="QrCode">二维码信息</param>
        /// <returns></returns>
        [HttpPost]
        [NoCheckJWT]
        public async Task<Object> GetAnalyticCode(string QrCode)
        {
            return await _pB_JobBookingBus.GetAnalyticCode(QrCode);
        }

        /// <summary>
        /// 解析二维码通用接口(输入)
        /// </summary>
        /// <param name="QrCode">二维码信息</param>
        /// <returns></returns>
        [HttpPost]
        [NoCheckJWT]
        public async Task<Object> GetAnalyticInputCode(string QrCode)
        {
            return await _pB_JobBookingBus.GetAnalyticInputCode(QrCode);
        }

        /// <summary>
        /// 获取全局变量
        /// </summary>
        /// <param name="LinkType">全局变量码</param>
        /// <returns></returns>
        [HttpPost]
        [NoCheckJWT]
        public async Task<Object> GetLinkTypeData(string LinkType)
        {
            return await _pB_JobBookingBus.GetLinkTypeDataAsync(LinkType);
        }


        /// <summary>
        /// 微信扫一扫识别物料二维码
        /// </summary>
        /// <param name="QrCode"></param>
        /// <returns></returns>
        [HttpPost]
        [NoCheckJWT]
        public async Task<ScanInfoByWX> GetMaterialInfoByScan(string QrCode)
        {
            return await _pB_JobBookingBus.GetMaterialInfoByScanAsync(QrCode);
        }

        #endregion

        #region 提交

        [HttpPost]
        public async Task SaveData(PB_JobBooking data)
        {
            if (data.Id.IsNullOrEmpty())
            {
                InitEntity(data);

                await _pB_JobBookingBus.AddDataAsync(data);
            }
            else
            {
                await _pB_JobBookingBus.UpdateDataAsync(data);
            }
        }

        /// <summary>
        /// PDA报工保存接口
        /// </summary>
        /// <param name="data">数据</param>
        /// <returns></returns>
        [HttpPost]
        public async Task AddData(List<PB_JobBookingDTOquery> data)
        {
            List<PB_JobBookingDTOquery> DataList = new List<PB_JobBookingDTOquery>();
            foreach (var item in data)
            {
                if (item.Id.IsNullOrEmpty())
                {
                    InitEntity(item);
                    DataList.Add(item);
                }
            }

            await _pB_JobBookingBus.AddData(DataList, _mongodbOptions);

        }

        /// <summary>
        /// 质检
        /// </summary>
        /// <param name="data">质检信息</param>
        /// <param name="userqrcode">用户二维码信息</param>
        /// <returns></returns>
        [HttpPost]
        public async Task UpdataListData(List<PB_JobBookingListDTO> data, string userqrcode)
        {
            await _pB_JobBookingBus.UpdataListData(data, userqrcode, _mongodbOptions);
        }

        [HttpPost]
        public async Task DeleteData(List<string> ids)
        {
            await _pB_JobBookingBus.DeleteDataAsync(ids);
        }

        /// <summary>
        /// 业务初始化打印,数据插入队列
        /// </summary>
        /// <param name="servicecode">业务码</param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Object> GetQueueListAsync(string servicecode)
        {
            return await _pB_JobBookingBus.GetQueueListAsync(servicecode, _mongodbOptions);
        }
        /// <summary>
        /// 推送打印队列
        /// </summary>
        /// <param name="InsertMongodbDTO"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<object> InsertMongodb(InsertMongodbDTO InsertMongodbDTO)
        {
            return await _pB_JobBookingBus.InsertMongodb(InsertMongodbDTO, _mongodbOptions);

        }

        /// <summary>
        /// 获取报工明细接口
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<PageResult<PB_JobBookingDetailedListDTO>> GetJobBookingDetailedListAsync(PageInput<PBJobBookingConditionDTO> input)
        {
            return await _pB_JobBookingBus.GetJobBookingDetailedListAsync(input);
        }

        /// <summary>
        /// PDA统计获取质检信息
        /// </summary>
        /// <param name="OrderDetailQrCode">任务单明细二维码</param>
        /// <returns></returns>
        [HttpPost]
        public async Task<List<PB_JobBookingDTO>> GetQualityTestingListAsync(string OrderDetailQrCode)
        {
            return await _pB_JobBookingBus.GetQualityTestingListAsync(OrderDetailQrCode);
        }

        /// <summary>
        /// PDA统计获取质检信息（输入）
        /// </summary>
        /// <param name="OrderDetailQrCode">任务单明细二维码</param>
        /// <returns></returns>
        [HttpPost]
        public async Task<List<PB_JobBookingDTO>> GetQualityTestingListInputAsync(string OrderDetailQrCode)
        {
            return await _pB_JobBookingBus.GetQualityTestingListInputAsync(OrderDetailQrCode);
        }

        /// <summary>
        /// 统计
        /// </summary>
        /// <param name="data">质检信息</param>
        /// 调整统计默认打印机   2022-03-01   赵锦涛
        /// <returns></returns>
        [HttpPost]
        public async Task UpdataStatisticsListData(List<PB_JobBookingListDTO> data)
        {
            await _pB_JobBookingBus.UpdataStatisticsListData(data, _mongodbOptions, _redisOptions);
        }

        /// <summary>
        /// 获取当前报工人是否有报工数据
        /// </summary>
        /// <param name="querydata"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<PB_JobBooking> GetTheUserListData(PB_JobBookingQueryDTO querydata)
        {
            return await _pB_JobBookingBus.GetTheUserListData(querydata);
        }

        /// <summary>
        /// 删除当前报工已存在且没有质检的数据
        /// </summary>
        /// <param name="querydata"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<PB_ProductionOrderDetailData> DelTheUserData(PB_JobBookingQueryDTO querydata)
        {
            return await _pB_JobBookingBus.DelTheUserData(querydata);
        }
        /// <summary>
        /// 获取登录人的打印机列表
        /// </summary>
        /// <param name="PrintType">打印机类型</param>
        /// <returns></returns>
        [HttpPost]
        public async Task<List<Printers>> GetPrinterListData(string PrintType)
        {
            return await _pB_JobBookingBus.GetPrinterListDataAsync(PrintType);
        }

        /// <summary>
        /// PDA统计物料打印
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task ProductPrint(ProductPrintData data)
        {
            await _pB_JobBookingBus.ProductPrintAsync(data, _mongodbOptions, _redisOptions);
        }

        /// <summary>
        /// PDA报工物料打印
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task WorkProductPrint(List<ProductPrintData> data)
        {
            await _pB_JobBookingBus.WorkProductPrintAsync(data, _mongodbOptions, _redisOptions);
        }
        /// <summary>
        /// 获取报工统计
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        /// 
        [HttpPost]
        public async Task<List<WorkReportingDto>> ViewWorkReportingDto(string month) {
            var list = await _pB_JobBookingBus.ViewWorkReportingDto(month);
            return list;
        }
        /// <summary>
        /// 获取报工人列表
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public async Task<List<ReportStatistics>> GetReportStatistics(string month) {
            var list = await _pB_JobBookingBus.GetReportStatistics(month);
            return list;
        }
        [HttpPost]
        public async Task<List<StatisticalDetails>> GetWorkReportingList(string UserId, string month) {
            var list = await _pB_JobBookingBus.GetWorkReportingList(UserId,month);
            return list;
        }


        [HttpGet]
        [NoCheckJWT]
        public async Task<IActionResult> GetExportViewWorkReportingDto(string month)
        {
            List<WorkReportingDto> listdata = await _pB_JobBookingBus.ViewWorkReportingDto(month);
            //创建EXCEL工作薄
            HSSFWorkbook workBook = new HSSFWorkbook();
            //创建sheet1文件表
            ISheet sheet = workBook.CreateSheet("报工查询");
            String Year = month.Split('-')[0].ToString();
            String Month = month.Split('-')[1].ToString();
            //创建表头
            IRow header = sheet.CreateRow(0);
            ICell cell = header.CreateCell(0);
            cell = header.CreateCell(0);
            cell.SetCellValue("报工人");
            cell = header.CreateCell(1);
            cell.SetCellValue("工序");
            cell = header.CreateCell(2);
            cell.SetCellValue(Year + "-"+ Month + "-01");
            cell = header.CreateCell(3);
            cell.SetCellValue(Year + "-" + Month + "-02");
            cell = header.CreateCell(4);
            cell.SetCellValue(Year + "-" + Month + "-03");
            cell = header.CreateCell(5);
            cell.SetCellValue(Year + "-" + Month + "-04");
            cell = header.CreateCell(6);
            cell.SetCellValue(Year + "-" + Month + "-05");
            cell = header.CreateCell(7);
            cell.SetCellValue(Year + "-" + Month + "06"); 
            cell = header.CreateCell(8);
            cell.SetCellValue(Year + "-" + Month + "-07"); 
            cell = header.CreateCell(9);
            cell.SetCellValue(Year + "-" + Month + "-08"); 
            cell = header.CreateCell(10);
            cell.SetCellValue(Year + "-" + Month + "-09"); 
            cell = header.CreateCell(11);
            cell.SetCellValue(Year + "-" + Month + "-10"); 
            cell = header.CreateCell(12);
            cell.SetCellValue(Year + "-" + Month + "-11"); 
            cell = header.CreateCell(13);
            cell.SetCellValue(Year + "-" + Month + "-12"); 
            cell = header.CreateCell(14);
            cell.SetCellValue(Year + "-" + Month + "-13"); 
            cell = header.CreateCell(15);
            cell.SetCellValue(Year + "-" + Month + "-14"); 
            cell = header.CreateCell(16);
            cell.SetCellValue(Year + "-" + Month + "-15");
            cell = header.CreateCell(17);
            cell.SetCellValue(Year + "-" + Month + "-16");
            cell = header.CreateCell(18);
            cell.SetCellValue(Year + "-" + Month + "-17");
            cell = header.CreateCell(19); 
            cell.SetCellValue(Year + "-" + Month + "-18");
            cell = header.CreateCell(20);
            cell.SetCellValue(Year + "-" + Month + "-19");
            cell = header.CreateCell(21);
            cell.SetCellValue(Year + "-" + Month + "-20");
            cell = header.CreateCell(22);
            cell.SetCellValue(Year + "-" + Month + "-21");
            cell = header.CreateCell(23);
            cell.SetCellValue(Year + "-" + Month + "-22");
            cell = header.CreateCell(24);
            cell.SetCellValue(Year + "-" + Month + "-23");
            cell = header.CreateCell(25);
            cell.SetCellValue(Year + "-" + Month + "-24");
            cell = header.CreateCell(26);
            cell.SetCellValue(Year + "-" + Month + "-25");
            cell = header.CreateCell(27);
            cell.SetCellValue(Year + "-" + Month + "-26");
            cell = header.CreateCell(28);
            cell.SetCellValue(Year + "-" + Month + "-27");
            cell = header.CreateCell(29);
            cell.SetCellValue(Year + "-" + Month + "-28");
            cell = header.CreateCell(30);
            cell.SetCellValue(Year + "-" + Month + "-29");
            cell = header.CreateCell(31);
            cell.SetCellValue(Year + "-" + Month + "-30");

                cell = header.CreateCell(32);
                cell.SetCellValue("报工数量");
                cell = header.CreateCell(33);
                cell.SetCellValue("统计数量");
          
            for (int i = 0; i < listdata.Count; i++)
            {
                IRow rowData = sheet.CreateRow(i + 1);
                ICell cel = rowData.CreateCell(0);
             

                cel = rowData.CreateCell(0);
                cel.SetCellValue(listdata[i].ReportUserName.ToString());

                cel = rowData.CreateCell(1);
                cel.SetCellValue(listdata[i].Name==null ? "0" :listdata[i].Name.ToString());

                cel = rowData.CreateCell(2);
                cel.SetCellValue(listdata[i].Day1.ToString());

                cel = rowData.CreateCell(3);
                cel.SetCellValue(listdata[i].Day2.ToString());

                cel = rowData.CreateCell(4);
                cel.SetCellValue(listdata[i].Day3.ToString());

                cel = rowData.CreateCell(5);
                cel.SetCellValue(listdata[i].Day4.ToString());

                cel = rowData.CreateCell(6);
                cel.SetCellValue(listdata[i].Day5.ToString());
                cel = rowData.CreateCell(7);
                cel.SetCellValue(listdata[i].Day6.ToString());
                cel = rowData.CreateCell(8);
                cel.SetCellValue(listdata[i].Day7.ToString());
                cel = rowData.CreateCell(9);
                cel.SetCellValue(listdata[i].Day8.ToString());
                cel = rowData.CreateCell(10);
                cel.SetCellValue(listdata[i].Day9.ToString());
                cel = rowData.CreateCell(11);
                cel.SetCellValue(listdata[i].Day10.ToString());
                cel = rowData.CreateCell(12);
                cel.SetCellValue(listdata[i].Day11.ToString());
                cel = rowData.CreateCell(13);
                cel.SetCellValue(listdata[i].Day12.ToString());
                cel = rowData.CreateCell(14);
                cel.SetCellValue(listdata[i].Day13.ToString());
                cel = rowData.CreateCell(15);
                cel.SetCellValue(listdata[i].Day14.ToString());
                cel = rowData.CreateCell(16);
                cel.SetCellValue(listdata[i].Day15.ToString());
                cel = rowData.CreateCell(17);
                cel.SetCellValue(listdata[i].Day16.ToString());
                cel = rowData.CreateCell(18);
                cel.SetCellValue(listdata[i].Day17.ToString());
                cel = rowData.CreateCell(19);
                cel.SetCellValue(listdata[i].Day18.ToString());
                cel = rowData.CreateCell(20);
                cel.SetCellValue(listdata[i].Day19.ToString());
                cel = rowData.CreateCell(21);
                cel.SetCellValue(listdata[i].Day20.ToString());
                cel = rowData.CreateCell(22);
                cel.SetCellValue(listdata[i].Day21.ToString());
                cel = rowData.CreateCell(23);
                cel.SetCellValue(listdata[i].Day22.ToString());
                cel = rowData.CreateCell(24);
                cel.SetCellValue(listdata[i].Day23.ToString());
                cel = rowData.CreateCell(25);
                cel.SetCellValue(listdata[i].Day24.ToString());
                cel = rowData.CreateCell(26);
                cel.SetCellValue(listdata[i].Day25.ToString());
                cel = rowData.CreateCell(27);
                cel.SetCellValue(listdata[i].Day26.ToString());
                cel = rowData.CreateCell(28);
                cel.SetCellValue(listdata[i].Day27.ToString());
                cel = rowData.CreateCell(29);
                cel.SetCellValue(listdata[i].Day28.ToString());
                cel = rowData.CreateCell(30);
                cel.SetCellValue(listdata[i].Day29.ToString());
                cel = rowData.CreateCell(31);
                cel.SetCellValue(listdata[i].Day30.ToString());
               
                    cel = rowData.CreateCell(32);
                    cel.SetCellValue(listdata[i].Subtotal.ToString());
                    cel = rowData.CreateCell(33);
                  cel.SetCellValue(listdata[i].StatisticalQuantity.ToString());


            }
            var expDir = string.Format("{0}Export\\{1}", System.AppDomain.CurrentDomain.BaseDirectory,
                 DateTime.Now.ToString("yyyyMM"));
            if (!Directory.Exists(expDir)) Directory.CreateDirectory(expDir);
            string filePath = string.Format("{0}\\CD{1}.xlsl", expDir, DateTime.Now.ToString("yyyyMMddHHmmss"));
            if (!Directory.Exists(filePath))
            {
                Directory.CreateDirectory(filePath);
            }
            string fileName = "报工查询.xlsx";
            //把Excel转为流，输出
            //创建文件流
            System.IO.MemoryStream bookStream = new System.IO.MemoryStream();
            //将工作薄写入文件流
            workBook.Write(bookStream);

            //输出之前调用Seek（偏移量，游标位置) 把0位置指定为开始位置
            bookStream.Seek(0, System.IO.SeekOrigin.Begin);
            //Stream对象,文件类型,文件名称
            return File(bookStream, "application/vnd.ms-excel", fileName);

        }

        /// <summary>
        /// PDA报工明细删除
        /// </summary>
        /// <param name="OrderDetailId">任务单明细Id</param>
        /// <returns></returns>
        [HttpPost]
        public async Task DelOrderDetailAsync(string OrderDetailId)
        {
            await _pB_JobBookingBus.DelOrderDetailAsync(OrderDetailId);
        }


        #region   PC报工(喷涂报工)

        /// <summary>
        /// 通用接口(PC报工)
        /// </summary>
        /// <param name="QrCode">二维码</param>
        /// <returns></returns>
        [HttpPost]
        [NoCheckJWT]
        public async Task<Object> GetUserInfo(string QrCode)
        {
            return await _pB_JobBookingBus.GetUserInfoAsync(QrCode);
        }

        /// <summary>
        /// 成品报工(最后一道工序)
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task WorkReportPrintList(WorkReportPrintData data)
        {
            await _pB_JobBookingBus.WorkReportPrintListAsync(data, _mongodbOptions, _redisOptions);
        }

        /// <summary>
        /// 成品报工信息(最后一道工序)
        /// </summary>
        /// <param name="UserQrcode">报工人二维码</param>
        /// <returns></returns>
        [HttpPost]
        public async Task<List<CirculationBillList>> GetCirculationBillList(string UserQrcode)
        {
            return await _pB_JobBookingBus.GetCirculationBillListAsync(UserQrcode);
        }

        #endregion

        #region  大屏接口

        /// <summary>
        /// 大屏显示当日合格数(件)
        /// </summary>
        /// <param name="Days">前第几天</param>
        /// <returns>当日合格数(件)</returns>
        [HttpPost]
        [NoCheckJWT]
        public ScreenDisplayValue3DTO GetTodayStatisticsNums(int Days = 0)
        {
            return _pB_JobBookingBus.GetTodayStatisticsNums(Days);
        }
        /// <summary>
        /// 大屏显示当日不良品数(件)
        /// </summary>
        /// <param name="Days">前第几天</param>
        /// <returns>当日不良品数(件)</returns>
        [HttpPost]
        [NoCheckJWT]
        public ScreenDisplayValue3DTO GetTodayNoPassNums(int Days = 0)
        {
            return _pB_JobBookingBus.GetTodayNoPassNums(Days);
        }
        /// <summary>
        /// 大屏显示当日良品率
        /// </summary>
        /// <param name="Days">前第几天</param>
        /// <returns>当日良品率</returns>
        [HttpPost]
        [NoCheckJWT]
        public ScreenDisplayDashboardDTO GetTodayPassRate(int Days = 0)
        {
            return _pB_JobBookingBus.GetTodayPassRate(Days);
        }
        /// <summary>
        /// 大屏显示指定车间当日质量合格率
        /// </summary>
        /// <param name="WorkShopName">车车间名称,比如"A1车间","A4车间"</param>
        /// <param name="Days">前第几天</param>
        /// <returns>当日良品率</returns>
        [HttpPost]
        [NoCheckJWT]
        public ScreenDisplayProgressDTO GetTodayPassRateByWorkShop(string WorkShopName = "", int Days = 0)
        {
            return _pB_JobBookingBus.GetTodayPassRateByWorkShop(WorkShopName, Days);
        }
        /// <summary>
        /// 大屏显示指定车间当月质量合格率
        /// </summary>
        /// <param name="WorkShopName">车车间名称,比如"A1车间","A4车间"</param>
        /// <param name="Month">前第几月</param>
        /// <returns>当月质量合格率</returns>
        [HttpPost]
        [NoCheckJWT]
        public ScreenDisplayProgressDTO GetMonthPassRate(string WorkShopName = "", int Month = 0)
        {
            return _pB_JobBookingBus.GetMonthPassRate(WorkShopName, Month);
        }
        ///// <summary>
        ///// 大屏显示指定车间当月产量(吨)
        ///// </summary>
        ///// <param name="WorkShopName">车间名称,比如"A1车间","A4车间"</param>
        ///// <param name="Month">前第几月</param>
        ///// <returns>当月合格数(件)</returns>
        //[HttpPost]
        //[NoCheckJWT]
        //public ScreenDisplayValueDTO GetMonthStatisticsNums(string WorkShopName="", int Month=0)
        //{
        //    return _pB_JobBookingBus.GetMonthStatisticsNums(WorkShopName,Month);
        //}
        /// <summary>
        /// 大屏显示七日产量(吨)
        /// </summary>
        /// <param name="Days">前第几天</param>
        /// <returns>七日产量(吨)</returns>
        [HttpPost]
        [NoCheckJWT]
        public PB_JobBooking7DayStatisticsNumsDTO GetSevenDaysStatisticsNums(int Days = 0)
        {
            return _pB_JobBookingBus.GetSevenDaysStatisticsNums(Days);
        }

        #endregion

        #region  工序流转报工


        /// <summary>
        /// 工序报工
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<WorkProject> WorkingProcedureWorkReport(WorkingProcedureData data)
        {
            return await _pB_JobBookingBus.WorkingProcedureWorkReportAsync(data);
        }

        /// <summary>
        /// 获取工序报工的物料信息
        /// </summary>
        /// <param name="DispatchDetailQrCode">派工单明细二维码</param>
        /// <returns></returns>
        [HttpPost]
        public async Task<PB_DispatchDetailProjectDTO> GetDispatchDetailProjectData(string DispatchDetailQrCode)
        {
            return await _pB_JobBookingBus.GetDispatchDetailProjectDataAsync(DispatchDetailQrCode);
        }

        /// <summary>
        /// 统计获取流转单的信息
        /// </summary>
        /// <param name="CirQrCode">流转单二维码</param>
        /// <returns></returns>
        [HttpPost]
        public async Task<PB_CirculationBillDTO> GetCirculationBillData(string CirQrCode)
        {
            return await _pB_JobBookingBus.GetCirculationBillDataAsync(CirQrCode);
        }

        /// <summary>
        /// 接收获取流转单的信息
        /// </summary>
        /// <param name="CirQrCode">流转单二维码</param>
        /// <returns></returns>
        [HttpPost]
        public async Task<PB_CirculationBillDTO> GetReceiveCirculationBillData(string CirQrCode)
        {
            return await _pB_JobBookingBus.GetReceiveCirculationBillDataAsync(CirQrCode);
        }

        /// <summary>
        /// 接收流转单
        /// </summary>
        /// <param name="CirBillQrCode">流转单二维码</param>
        /// <param name="Nums">接收数量</param>
        /// <returns></returns>
        [HttpPost]
        public async Task ReceiveCirculationBill(string CirBillQrCode, Double? Nums)
        {
            await _pB_JobBookingBus.ReceiveCirculationBillAsync(CirBillQrCode, Nums);
        }

        /// <summary>
        /// 流转单质检
        /// </summary>
        /// <param name="CirBillQrCode">流转单二维码</param>
        /// <param name="Nums">统计数量</param>
        /// <returns></returns>
        [HttpPost]
        public async Task QualityCirculationBill(string CirBillQrCode, Double? Nums)
        {
            await _pB_JobBookingBus.QualityCirculationBillAsync(CirBillQrCode, Nums);
        }


        /// <summary>
        /// 流转单统计
        /// </summary>
        /// <param name="CirBillQrCode">流转单二维码</param>
        /// <param name="Nums">统计数量</param>
        /// <returns></returns>
        [HttpPost]
        public async Task StatisticsCirculationBill(string CirBillQrCode, Double? Nums)
        {
            await _pB_JobBookingBus.StatisticsCirculationBillAsync(CirBillQrCode, Nums);
        }

        /// <summary>
        /// 工序流转单补打
        /// </summary>
        /// <param name="DispatchDetailQrCode">派工单明细二维码</param>
        /// <returns></returns>
        [HttpPost]
        public async Task<List<WorkProject>> GetCirculationBillPrint(string DispatchDetailQrCode)
        {
            return await _pB_JobBookingBus.GetCirculationBillPrintAsync(DispatchDetailQrCode);
        }
        /// <summary>
        /// PDA快速质检
        /// </summary>
        /// <param name="Data">质检数据</param>
        /// <param name="_mongodbOptions"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task UpdataRapidInspection(QuickWorkReportData Data) {
            await _pB_JobBookingBus.UpdataRapidInspection(Data) ;
        }
        #endregion

        #region 翻新领料生成翻新出库流转卡

        /// <summary>
        /// 获取翻新出库的生产任务明细信息(作废)
        /// </summary>
        /// <param name="OrderDetailQrCode">任务单明细二维码</param>
        /// <returns></returns>
        [HttpPost]
        public async Task<OrderDetailMaterialData> GetOrderDetailCirBillData(string OrderDetailQrCode)
        {
            return await _pB_JobBookingBus.GetOrderDetailCirBillDataAsync(OrderDetailQrCode);
        }

        /// <summary>
        /// 翻新生产任务单生成翻新出库流转卡(作废)
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<WorkProject> AddCirculationBillDataAsync(OrderDetailData data)
        {
            return await _pB_JobBookingBus.AddCirculationBillDataAsync(data);
        }

        /// <summary>
        /// 翻新领料
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<WorkProject> RefurbishmentPicking(RefurbishmentData data)
        {
            return await _pB_JobBookingBus.RefurbishmentPickingAsync(data);
        }

        /// <summary>
        /// 翻新领料获取包信息
        /// </summary>
        /// <param name="PackQrCode">包二维码</param>
        /// <param name="OrderQrCode">任务单二维码</param>
        /// <returns></returns>
        [HttpPost]
        public async Task<CirPackListData> GetCirPackListData(string PackQrCode, string OrderQrCode)
        {
            return await _pB_JobBookingBus.GetCirPackListDataAsync(PackQrCode, OrderQrCode);
        }

        /// <summary>
        /// 翻新流转单补打
        /// </summary>
        /// <param name="DispatchDetailQrCode">派工单明细二维码</param>
        /// <returns></returns>
        [HttpPost]
        public async Task<List<WorkProject>> GetOrderDetailCirBillPrintAsync(string DispatchDetailQrCode)
        {
            return await _pB_JobBookingBus.GetOrderDetailCirBillPrintAsync(DispatchDetailQrCode);
        }

        /// <summary>
        /// 扫描生产任务单明细二维码获取物料信息
        /// </summary>
        /// <param name="orderdetailQrcode">生产任务单明细二维码</param>
        /// <param name="LocaQrcode">货位二维码</param>
        /// <returns></returns>
        [HttpPost]
        public async Task<OrderDetailMaterialDTO> GetOrderDetailMaterial(string orderdetailQrcode, string LocaQrcode)
        {
            return await _pB_JobBookingBus.GetOrderDetailMaterialAsync(orderdetailQrcode, LocaQrcode);
        }

        /// <summary>
        /// 翻新领料(根据生产任务单明细输入数量)
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<WorkProject> RefurMaterialPicking(RefurMaterialData data)
        {
            return await _pB_JobBookingBus.RefurMaterialPickingAsync(data);
        }

        #endregion

        #region 维修改制

        /// <summary>
        /// 领料根据货位获取仓库物料信息
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<PageResult<WXGZLocaMaterialDTO>> GetWXGZLocaMaterialList(PageInput<WXGZConditionDTO> input)
        {
            return await _pB_JobBookingBus.GetWXGZLocaMaterialListAsync(input);
        }

        /// <summary>
        /// 维修改制领料保存
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task SaveWXGZLocalMaterialData(WXGZmaterialData data)
        {
            await _pB_JobBookingBus.SaveWXGZLocalMaterialDataAsync(data);
        }

        /// <summary>
        /// 获取维修改制领料记录
        /// </summary>
        /// <param name="OrderDetailQrCode">任务单明细二维码</param>
        /// <returns></returns>
        [HttpPost]
        public async Task<List<ReformMaterialReceiveDTO>> GetReformMaterialReceiveList(string OrderDetailQrCode)
        {
            return await _pB_JobBookingBus.GetReformMaterialReceiveListAsync(OrderDetailQrCode);
        }

        /// <summary>
        /// 维修改制领料提交(生产出库单)
        /// </summary>
        /// <param name="OrderDetailQrCode">任务单明细二维码</param>
        /// <returns></returns>
        [HttpPost]
        public async Task SubmitReformMaterialReceiveAsync(string OrderDetailQrCode)
        {
            await _pB_JobBookingBus.SubmitReformMaterialReceiveAsync(OrderDetailQrCode);
        }

        /// <summary>
        /// 维修改制领料移除
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task DeleteReformMaterialReceiveAsync(ReformMaterialReceiveDTO data)
        {
            await _pB_JobBookingBus.DeleteReformMaterialReceiveAsync(data);
        }

        /// <summary>
        /// 扫描任务单明细二维码获取任务单明细信息
        /// </summary>
        /// <param name="OrderDetailQrCode">任务单明细二维码</param>
        /// <returns></returns>
        [HttpPost]
        public async Task<PB_ProductionOrderDetail> GetProductionOrderDetailData(string OrderDetailQrCode)
        {
            return await _pB_JobBookingBus.GetProductionOrderDetailDataAsync(OrderDetailQrCode);
        }

        #endregion

        #region  打印服务

        /// <summary>
        /// 校验组织编码,并返回组织信息和打印机信息
        /// </summary>
        /// <param name="DeptCode">组织编码</param>
        /// <returns></returns>
        [HttpPost]
        [NoCheckJWT]
        public async Task<DepartmentPrintDTO> GetDepartmentData(string DeptCode)
        {
            return await _pB_JobBookingBus.GetDepartmentDataAsync(DeptCode);
        }

        #endregion


        #endregion
    }
}